package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Zhexiantu;
import com.bw.mapper.StudentMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class StudentController {

    @Autowired
    StudentMapper studentMapper;

    @RequestMapping("/tuPage.do")
    public String tuPage(){

        return "tu";// 只能返回页面
    }

    @RequestMapping("/zxt.do")
    @ResponseBody //  返回值不再返回页面，  返回一个Json格式的数据
    public List<Zhexiantu> zxt(Integer groupId){
        List<Zhexiantu>  list = studentMapper.zxtByGroupId(groupId);
        return list;
    }

    @RequestMapping("/bing.do")
    @ResponseBody //  返回值不再返回页面，  返回一个Json格式的数据
    public List<Bing> bing(){
        List<Bing>  list = studentMapper.bing();
        return list;
    }


    @RequestMapping("/excel.do")
    public void excel(HttpServletResponse response){
        List<Bing>  list = studentMapper.bing();

        ExcelUtils.exportExcel(list,"学生数量导出","sheet页",response);

    }
}
